package com.rs.game.player.content;

import com.rs.game.Animation;
import com.rs.game.player.Player;
import com.rs.game.player.Skills;

/**
 * @author Swirl <obruza@gmail.com>
 */
public class ConstructFurniture {
	public static int CFG = 397; // <-- This is the construction skill board.

	// private Player player; <-- Pointless add if needed

	public static void handleButtons(Player player, int componentId) {
		switch (componentId) {
		case 45: // Chair
			if (player.getInventory().containsItem(960, 2)) {
				player.getSkills().addXp(Skills.CONSTRUCTION, 75);
				player.getPackets().sendGameMessage("You build an armchair.");
				player.setNextAnimation(new Animation(883));
				player.getInventory().deleteItem(960, 2);
				player.closeInterfaces();
			} else {
				player.getPackets().sendGameMessage("You need 2 planks to build an armchair.");
			}
			break;
		case 46: // Bookcase
			if (player.getInventory().containsItem(960, 4)) {
				player.getSkills().addXp(Skills.CONSTRUCTION, 111);
				player.getPackets().sendGameMessage("You build a bookcase.");
				player.setNextAnimation(new Animation(883));
				player.getInventory().deleteItem(960, 4);
				player.closeInterfaces();
			} else {
				player.getPackets().sendGameMessage("You need 4 planks to build a bookcase.");
			}
			break;
		case 47: // Beer Barrel
			if (player.getInventory().containsItem(8778, 4)) {
				player.getSkills().addXp(Skills.CONSTRUCTION, 165);
				player.getPackets().sendGameMessage("You build a beer barrel.");
				player.setNextAnimation(new Animation(883));
				player.getInventory().deleteItem(8778, 4);
				player.closeInterfaces();
			} else {
				player.getPackets().sendGameMessage("You need 4 oak planks to build a beer barrel.");
			}
			break;
		case 48: // Kitchen Table
			if (player.getInventory().containsItem(8778, 8)) {
				player.getSkills().addXp(Skills.CONSTRUCTION, 165);
				player.getPackets().sendGameMessage("You build a kitchen table.");
				player.setNextAnimation(new Animation(883));
				player.getInventory().deleteItem(8778, 8);
				player.closeInterfaces();
			} else {
				player.getPackets().sendGameMessage("You need 8 oak planks to build a kitchen table.");
			}
			break;
		case 49: // Dining Table
			if (player.getInventory().containsItem(8778, 4) && player.getInventory().containsItem(960, 1)) {
				player.getSkills().addXp(Skills.CONSTRUCTION, 265);
				player.getPackets().sendGameMessage("You build a dining table.");
				player.setNextAnimation(new Animation(883));
				player.getInventory().deleteItem(8778, 4);
				player.getInventory().deleteItem(960, 1);
				player.closeInterfaces();
			} else {
				player.getPackets().sendGameMessage("You need 4 oak planks & 1 plank to build a dining table.");
			}
			break;
		case 50: // Dining Bench
			if (player.getInventory().containsItem(8780, 2) && player.getInventory().containsItem(960, 1)) {
				player.getSkills().addXp(Skills.CONSTRUCTION, 400);
				player.getPackets().sendGameMessage("You build a dining bench.");
				player.setNextAnimation(new Animation(883));
				player.getInventory().deleteItem(8780, 2);
				player.getInventory().deleteItem(960, 1);
				player.closeInterfaces();
			} else {
				player.getPackets().sendGameMessage("You need 2 teak planks & 1 plank to build a dining bench.");
			}
			break;
		}
	}
}
